package pages;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.*;

import java.io.File;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: Lazarenok
 * Date: 21.11.13
 * Time: 22:32
 * To change this template use File | Settings | File Templates.
 */
public class SummaryPage {

    public WebDriver driver;

    public SummaryPage(WebDriver driver) {
        this.driver = driver;
    }

    public void openPage() {
        WebElement summary = driver.findElement(By.xpath("//*[@id=\"tab-home\"]"));
        summary.click();
    }

    public boolean checkURL() throws IOException {
        String targetURL = driver.getCurrentUrl();
        File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
        FileUtils.copyFile(scrFile, new File("C:\\screenshots\\Summary.png"));
        return (targetURL.contains("#/home"));
    }


}
